home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Sprites / AGASprites.s next >
Encoding:
Text File  |  1997-05-10  |  4.3 KB  |  196 lines

  1. ;Sprite Example (AGA only)
  2. ;-------------------------
  3. ;This example contains four 64 pixel wide sprites, in high resolution.
  4. ;You can move sprite number 2 around with the mouse, notice how it
  5. ;appears behind number 1 and in front of 3 and 4.
  6. ;
  7. ;This demo also uses the LIST feature to initialise the four sprites.
  8. ;
  9. ;The LMB exits the demo.
  10.  
  11.     INCDIR    "INCLUDES:"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i"
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19.     SECTION    "Sprites",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25.     STARTGMS
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    GMSBase(pc),a6
  29.     lea    ScreenTags(pc),a0    ;Initialise our screen for use.
  30.     CALL    ShowScreen    ;Show our screen.
  31.     tst.l    d0
  32.     beq.s    .Error_Screen
  33.  
  34.     move.l    Screen(pc),a0
  35.     lea    SpriteList(pc),a1
  36.     CALL    InitSprite
  37.     tst.l    d0
  38.     beq.s    .Error_Sprite
  39.  
  40.     move.l    Circle1(pc),a1
  41.     CALL    UpdateSprite
  42.     move.l    Circle3(pc),a1
  43.     CALL    UpdateSprite
  44.     move.l    Circle4(pc),a1
  45.     CALL    UpdateSprite
  46.  
  47.     CALL    InitJoyPorts
  48.  
  49.     bsr.s    Main
  50.  
  51. .ReturnToDOS
  52.     move.l    GMSBase(pc),a6
  53.     lea    SpriteList(pc),a1
  54.     CALL    FreeSprite
  55. .Error_Sprite
  56.     move.l    Screen(pc),a0
  57.     CALL    DeleteScreen
  58. .Error_Screen
  59.     MOVEM.L    (SP)+,A0-A6/D1-D7
  60.     moveq    #ERR_OK,d0
  61.     rts
  62.  
  63. ;===========================================================================;
  64. ;                                MAIN LOOP
  65. ;===========================================================================;
  66.  
  67. Main:    move.l    Circle2(pc),a1
  68. .loop    moveq    #JPORT1,d0    ;Read from port 1
  69.     CALL    ReadMouse    ;Go get mouse position.
  70.     move.w    d0,d1
  71.     asr.w    #8,d0
  72.     add.w    d0,SPR_XPos(a1)
  73.     ext.w    d1
  74.     add.w    d1,SPR_YPos(a1)
  75.  
  76.     CALL    WaitVBL    ;Allow screen-switching.
  77.     CALL    UpdateSprite    ;Put Sparkie on the screen.
  78.  
  79.     btst    #MB_LMB,d0
  80.     beq.s    .loop
  81.     rts
  82.  
  83. ;===========================================================================;
  84. ;                                  DATA
  85. ;===========================================================================;
  86.  
  87. SpriteList:
  88.     dc.l    LIST
  89.     dc.l    TAGS_Circle1
  90.     dc.l    TAGS_Circle2
  91.     dc.l    TAGS_Circle3
  92.     dc.l    TAGS_Circle4
  93.     dc.l    LISTEND
  94.  
  95. TAGS_Circle1:
  96.     dc.l    TAGS_SPRITE
  97. Circle1    dc.l    0
  98.     dc.l    SPA_Data,Gfx_Circle1
  99.     dc.l    SPA_XCoord,20
  100.     dc.l    SPA_YCoord,20
  101.     dc.l    SPA_Width,64
  102.     dc.l    SPA_Height,64
  103.     dc.l    SPA_AmtColours,16
  104.     dc.l    SPA_ColStart,16
  105.     dc.l    SPA_Planes,2
  106.     dc.l    SPA_ScrMode,HIRES
  107.     dc.l    TAGEND
  108.  
  109. TAGS_Circle2:
  110.     dc.l    TAGS_SPRITE
  111. Circle2    dc.l    0
  112.     dc.l    SPA_Number,2
  113.     dc.l    SPA_Data,Gfx_Circle2
  114.     dc.l    SPA_XCoord,70
  115.     dc.l    SPA_YCoord,70
  116.     dc.l    SPA_Width,64
  117.     dc.l    SPA_Height,64
  118.     dc.l    SPA_AmtColours,16
  119.     dc.l    SPA_ColStart,16
  120.     dc.l    SPA_Planes,2
  121.     dc.l    SPA_ScrMode,HIRES
  122.     dc.l    TAGEND
  123.  
  124. TAGS_Circle3:
  125.     dc.l    TAGS_SPRITE
  126. Circle3    dc.l    0
  127.     dc.l    SPA_Number,4
  128.     dc.l    SPA_Data,Gfx_Circle3
  129.     dc.l    SPA_XCoord,120
  130.     dc.l    SPA_YCoord,120
  131.     dc.l    SPA_Width,64
  132.     dc.l    SPA_Height,64
  133.     dc.l    SPA_AmtColours,16
  134.     dc.l    SPA_ColStart,16
  135.     dc.l    SPA_Planes,2
  136.     dc.l    SPA_ScrMode,HIRES
  137.     dc.l    TAGEND
  138.  
  139. TAGS_Circle4:
  140.     dc.l    TAGS_SPRITE
  141. Circle4    dc.l    0
  142.     dc.l    SPA_Number,6
  143.     dc.l    SPA_Data,Gfx_Circle4
  144.     dc.l    SPA_XCoord,170
  145.     dc.l    SPA_YCoord,170
  146.     dc.l    SPA_Width,64
  147.     dc.l    SPA_Height,64
  148.     dc.l    SPA_AmtColours,16
  149.     dc.l    SPA_ColStart,16
  150.     dc.l    SPA_Planes,2
  151.     dc.l    SPA_ScrMode,HIRES
  152.     dc.l    TAGEND
  153.  
  154. ScreenTags:
  155.     dc.l    TAGS_GAMESCREEN
  156. Screen:    dc.l    0
  157.     dc.l    GSA_Palette,.palette
  158.     dc.l    GSA_AmtColours,32
  159.     dc.l    GSA_ScrWidth,320
  160.     dc.l    GSA_ScrHeight,256
  161.     dc.l    GSA_Planes,1
  162.     dc.l    GSA_Attrib,SPRITES|NOSCRBDR
  163.     dc.l    TAGEND
  164.  
  165. .palette
  166.     dc.l    $000000,$0F0000,$1F0000,$2F0000,$3F0000,$4F0000
  167.     dc.l    $5F0000,$6F0000,$7F0000,$8F0000,$9F0000,$AF0000
  168.     dc.l    $BF0000,$CF0000,$DF0000,$EF0000,$FF0000,$001111
  169.     dc.l    $002222,$003333,$004444,$005555,$006666,$007777
  170.     dc.l    $008888,$009999,$00AAAA,$00BBBB,$00CCCC,$00DDDD
  171.     dc.l    $00EEEE,$00FFFF
  172.  
  173. ;===========================================================================;
  174. ;                         ALL CHIP RAM DATA HERE
  175. ;===========================================================================;
  176.  
  177.     SECTION    "Graphics",DATA_C
  178.  
  179.     CNOP    0,4    ;Sprite must be 64bit aligned.
  180. Gfx_Circle1:
  181.     INCBIN    "GMS:demos/data/RAW.CircleSpr1"
  182.  
  183.     CNOP    0,4    ;Sprite must be 64bit aligned.
  184. Gfx_Circle2:
  185.     INCBIN    "GMS:demos/data/RAW.CircleSpr2"
  186.  
  187.     CNOP    0,4    ;Sprite must be 64bit aligned.
  188. Gfx_Circle3:
  189.     INCBIN    "GMS:demos/data/RAW.CircleSpr3"
  190.  
  191.     CNOP    0,4    ;Sprite must be 64bit aligned.
  192. Gfx_Circle4:
  193.     INCBIN    "GMS:demos/data/RAW.CircleSpr3"
  194.  
  195.  
  196.